package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"time"
)

func main() {
	method := "GET"
	uri := "https://example.com"

	ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
	defer cancel()

	req, err := http.NewRequest(method, uri, nil)
	if err != nil {
		panic(err)
	}
	req = req.WithContext(ctx)

	client := &http.Client{}
	resp, err := client.Do(req)
	client.Get(uri)
	// resp, err := http.Get(uri)
	if err != nil {
		panic(err)
	}
	defer func(Body io.ReadCloser) {
		err := Body.Close()
		if err != nil {
			panic(err)
		}
	}(resp.Body)

	fmt.Println(resp.Status)
}
